﻿#include "Head.h"
int main()
{
	//基本初始化
	InitAudioDevice();
	InitWindow(Lenth, Width, "BE A SWORDER!");
	FILE* f = fopen("./resource/zombi.ico", "rb");
	Image icon1 = LoadImage("./resource/zombi.png");//图标
	SetWindowIcon(icon1);
	//载入音乐扩展
	MusicDLC();
	//主菜单初始化
	InitMenu(Lenth,Width);
	//随机值初始化
	SetRandomSeed((unsigned int)time(NULL));
	//基本音频初始化
	Music menubgm = LoadMusicStream("./resource/menubgm.mp3");//我想把整片天空打开！！！
	SetMusicVolume(menubgm, 0.1f);
	button1 = LoadSound("./resource/button.ogg");
	button2 = LoadSound("./resource/button2.ogg");
	//背景音乐
	PlayMusicStream(menubgm);
	//帧率
	SetTargetFPS(180);
	//计时器
	float exit = 0;
	//主循环
	while (!WindowShouldClose())
	{	
		//输入处理
		// 光标等前置数据载入&处理
		PreData();
		//菜单输入处理
		if(GameIs==0)
		{
			if (TextureIsClicked(rectangle_depth, StartButtonPosition))
			{
				PlaySound(button1);
				//WaitTime(0.15);
				GameIs = 1;
			}
			if (TextureIsClicked(rectangle_depth, ExitButtonPosition))
			{
				PlaySound(button2);
				GameIs = 2;
			}
			if (TextureIsClicked(zombi, zombiPosition))
			{
				PlaySound(steve_hurt);
			}
		}
		//状态更新
		if (GameIs == 1)
		{
			Game();
		}
		if (GameIs == 2)
		{
			WaitTime(0.5);
			break;
		}
		//渲染
		BeginDrawing();
		ClearBackground(GRAY);//刷新
		DrawCircleLinesV(MousePosition, 8, RED);//光标
		DrawCircleV(MousePosition, 3.5, RED);
		if(GameIs==0)
		{
			DrawMenu(StartButtonPosition, ExitButtonPosition);
		}
		EndDrawing();
		//音乐逐帧播放;
		UpdateMusicStream(menubgm);
	}
	//释放
	UnloadFont(GameFont);
	CloseAudioDevice();
	CloseWindow();
	UnloadImage(icon1);
	return 0;
}